package servlet;


import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bean.Shop;

import service.ShopService;

public class ShopServlet extends HttpServlet {
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//接收标签m
		String m = request.getParameter("m");
		
		if ("list".equals(m)) {
			list(request,response);
		}
			
	}

	private void list(HttpServletRequest request, HttpServletResponse response) {
		try {
			//创建service
			ShopService service = new ShopService();
			//掉用
			List<Shop> list = service.list();
			//添加作用域
			request.setAttribute("list", list);
			//转发
			request.getRequestDispatcher("list.jsp").forward(request, response);
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
}
